package bamin.com.bamindaijia.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.amap.api.services.help.Tip;

import java.util.List;

import bamin.com.bamindaijia.R;

public class MySearchAdapter extends BaseAdapter {
    private List<Tip> listSearch;
    private LayoutInflater inflater;
    class ViewHolder {
        TextView textView_poi;
        TextView textView_detail;
    }
    public MySearchAdapter(Context context, List<Tip> listSearch) {
        this.listSearch = listSearch;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return listSearch.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.site_item, null);

            holder.textView_poi = (TextView) convertView.findViewById(R.id.textView_poi);
            holder.textView_detail = (TextView) convertView.findViewById(R.id.textView_detail);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }

        holder.textView_poi.setText(listSearch.get(position).getName());
        holder.textView_detail.setText(listSearch.get(position).getDistrict());
        return convertView;
    }


}